package com.fau.hm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc  话务任务待处理实体类
 * @author yangzj
 * @datetime 2014年10月14日,下午5:31:27
 */
@Entity
@Table(name = "medical_call_pending")
public class MedicalCallPending implements Serializable, JSONAware{
	
	private static final long serialVersionUID = -7273421629364230049L;
	
	private String id; 				// 话务任务表id
	
	@Length(max = 20, message = "编号长度需要在0和20之间")
	private String serialNum; 		// 编号
	
	@NotBlank(message = "任务类别不能为空！")
	@Length(max = 10, message = "任务类别长度需要在0和10之间")
	private String category; 		// 任务类别
	
	private String pocessingStatus; // 处理状态
	
	@Length(max = 85, message = "备注长度需要在0和85之间")
	private String remark; 			// 备注
	
	@NotBlank(message = "创建者不能为空！")
	@Length(max = 32, message = "创建者长度需要在0和32之间")
	private String createUser; 		// 创建者
	
	@Length(max = 32, message = "处理者长度需要在0和32之间")
	private String handleUserId;		// 处理者
	
	@Length(max = 20, message = "外线号码长度需要在0和20之间")
	private String outsideNum;		// 外线号码
	
	@NotBlank(message = "相关号码不能为空！")
	@Length(max = 20, message = "相关号码长度需要在0和20之间")
	private String relatedPhone;	// 相关号码
	
	private Date allocationTime;	// 分配时间
	
	private Date createTime = new Date(); 		// 创建时间
	
	private Date updateTime = new Date();		// 更新时间
	
	@Length(max = 32, message = "坐席长度需要在0和32之间")
	private String centerId;		// 中心id
	
	@Length(max = 32, message = "坐席长度需要在0和32之间")
	private String groupId;			// 组id
	
	private String hospitalId;		// 医院企业id
	private String grade;			// 企业所处级别
	
	private String keyType;			// 字典表类型
	private String keyPid;			// 字典表父id
	private String keyVal;			// 字典表值
	private String listType;		// 列表类型  0未分配列表 1 任务管理列表
	
	@Id
	@GenericGenerator(name = "generator", strategy = "assigned")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "serial_num", length = 20)
	public String getSerialNum() {
		return serialNum;
	}

	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}

	@Column(name = "category", length = 32)
	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	@Transient
	public String getPocessingStatus() {
		return pocessingStatus;
	}

	public void setPocessingStatus(String pocessingStatus) {
		this.pocessingStatus = pocessingStatus;
	}

	@Column(name = "remark", length = 255)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "create_user", length = 32)
	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	
	@Column(name = "handle_user_id", length = 32)
	public String getHandleUserId() {
		return handleUserId;
	}

	public void setHandleUserId(String handleUserId) {
		this.handleUserId = handleUserId;
	}
	
	@Column(name = "outside_num", length = 20)
	public String getOutsideNum() {
		return outsideNum;
	}

	public void setOutsideNum(String outsideNum) {
		this.outsideNum = outsideNum;
	}

	@Column(name = "related_phone", length = 20)
	public String getRelatedPhone() {
		return relatedPhone;
	}

	public void setRelatedPhone(String relatedPhone) {
		this.relatedPhone = relatedPhone;
	}

	@Column(name = "allocation_time")
	public Date getAllocationTime() {
		return allocationTime;
	}

	public void setAllocationTime(Date allocationTime) {
		this.allocationTime = allocationTime;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "center_id", length = 32)
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}
	
	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}
	
	@Column(name = "grade", length = 5)
	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	@Transient
	public String getKeyType() {
		return keyType;
	}

	public void setKeyType(String keyType) {
		this.keyType = keyType;
	}

	@Transient
	public String getKeyPid() {
		return keyPid;
	}

	public void setKeyPid(String keyPid) {
		this.keyPid = keyPid;
	}

	@Transient
	public String getKeyVal() {
		return keyVal;
	}

	public void setKeyVal(String keyVal) {
		this.keyVal = keyVal;
	}
	
	@Transient
	public String getListType() {
		return listType;
	}

	public void setListType(String listType) {
		this.listType = listType;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("serialNum", serialNum);
		obj.put("category", category);
		obj.put("remark", remark);
		obj.put("createUser", createUser);
		obj.put("outsideNum", outsideNum);
		obj.put("handleUserId", handleUserId);
		obj.put("relatedPhone", relatedPhone);
		if(this.allocationTime != null){
			obj.put("allocationTime", DateFormatUtils.format(this.allocationTime,"yyyy-MM-dd HH:mm:ss"));
		}
		if(this.createTime != null){
			obj.put("createTime", DateFormatUtils.format(this.createTime,"yyyy-MM-dd HH:mm:ss"));
		}
		return obj.toString();
	}
}
